package com.learn.springcloud.web;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import com.learn.dubbo.core.util.JsonUtil;

@Component
public class RestfulUtil {
	
	@Autowired
	public RestTemplate restTemplate;
	
	public String getResult(Map<String,Object> map){
		String result = null;
		String param = JsonUtil.writeValueAsString(map);
		//通过编码获取url
		String url = "http://"+map.get("server")+"/"+map.get("method")+"?param={param}";
		result = restTemplate.postForObject(url, null,String.class,param);
		return result;
	}

}
